var worldCloudcharts = echarts.init(document.getElementById('ciyun'));
var worldCloudoption = {
    tooltip: {
        show: true
    },
    series: [{
        name: '热点词语',
        type: 'wordCloud',
        sizeRange: [6, 66],
        rotationRange: [-45, 90],
        textPadding: 0,
        autoSize: {
            enable: true,
            minSize: 6
        },
        textStyle: {
            normal: {
                color: function () {
                    return 'rgb(' + [
                        Math.round(Math.random() * 160),
                        Math.round(Math.random() * 160),
                        Math.round(Math.random() * 160)
                    ].join(',') + ')';
                }
            },
            emphasis: {
                shadowBlur: 10,
                shadowColor: '#333'
            }
        },
        data: []
    }]
};


var node_phone_num = $.cookie("node_phone_num")
console.log(node_phone_num)
$(function () {
    console.log(node_phone_num)
    var data = {phone_num: node_phone_num}

    $.ajax({
        url: "http://127.0.0.1:9998/analysis/get_key_person_info/" +data.phone_num,
        type: "POST",
        time: '3000',
        dataType: "json",
        data: data,
        success: function (response) {
            console.log(response);
            const key_person_info = response.data;
            if (response.code === 1) {

                $('#eventnametext').text(key_person_info.thisUserInfo.phoneNum)
                var XiangXi_str = ""
                XiangXi_str = XiangXi_str +
                    "<tr><td style='font-size: 15px'>" + "用户号码 :" + key_person_info.thisUserInfo.phoneNum + "</td></tr>" +
                    "<tr><td style='font-size: 15px'>" + "用户城市 :" + key_person_info.thisUserInfo.city + "</td></tr>" +
                    "<tr><td style='font-size: 15px'>" + "用户标签 :" + key_person_info.thisUserInfo.userLabel + "</td></tr>" +
                    "<tr><td style='font-size: 15px'>" + "用户影响力 :" + key_person_info.thisUserInfo.influence + "</td></tr>" +
                    "<tr><td style='font-size: 15px'>" + "是否为海外用户 :" + (key_person_info.thisUserInfo.isOverseasUser == "N" ? "否" : "是") + "</td></tr>" +
                    "<tr><td style='font-size: 15px'>" + "用户政治倾向 :" + (key_person_info.thisUserInfo.isSensitiveUser == null ? "正面" : "负面") + "</td></tr>" +
                    "<tr><td style='font-size: 15px'>" + "用户敏感词 :" + (key_person_info.thisUserInfo.sensitiveWord == null ? "无" : key_person_info.thisUserInfo.sensitiveWord) + "</td></tr>"

                $('#XiangXiXinXi').append(XiangXi_str)

                // 右侧
                var usuContact = key_person_info.frequentContacts

                var str_gr_usualContact = ""
                var j = 1
                for (var one in usuContact) {                         //遍历一下
                    str_gr_usualContact = str_gr_usualContact + "<tr><td style='font-size: 15px'>" + j + ":</td>" + "<td style='font-size: 15px'>"
                        + usuContact[one].phoneNum + "</td>" + "<td style='font-size: 15px'> - " + usuContact[one].relation + "</td></tr>" //选择要哪个
                    j = j + 1;
                }
                $('#usualContact').append(str_gr_usualContact);

                var JsonList = []
                // 词云图
                data_name = key_person_info.thisUserInfo.keyword.split(",")    //都拿来
                for (var one in data_name) {                   //一个一个遍历
                    var word_name = {}
                    word_name['name'] = data_name[one]
                    word_name['value'] = "800"
                    JsonList.push(word_name)
                }
                worldCloudoption.series[0].data = JsonList;
                worldCloudcharts.setOption(worldCloudoption);
            }
        },
    });
});